<div class="container">
  

        <h1 id="pkg-overview">package iotest</h1>

        <p><code>import "testing/iotest"</code>

        </p><p>
Package iotest implements Readers and Writers useful mainly for testing.</p>


        
  


        
        

        

        

        
        
          
        

        
        


<p><a href="https://github.com/golang/go/blob/master/src/testing/iotest/logger.go">logger.go</a> <a href="https://github.com/golang/go/blob/master/src/testing/iotest/reader.go">reader.go</a> <a href="https://github.com/golang/go/blob/master/src/testing/iotest/writer.go">writer.go</a> </p>

        
        

        
        
          <h2 id="pkg-variables">Variables </h2>
          
        

        
        
        
          <h2 data-kind="f" id="DataErrReader">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/reader.go#L45" title="View Source">DataErrReader</a>  </h2>
          <p>
DataErrReader changes the way errors are handled by a Reader. Normally, a
Reader returns an error (typically EOF) from the first Read call after the
last piece of data is read. DataErrReader wraps a Reader and changes its
behavior so the final error is returned along with the final data, instead
of in the first call after the final data.
</p>

          
  

        
          <h2 data-kind="f" id="HalfReader">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/reader.go#L30" title="View Source">HalfReader</a>  </h2>
          <p>
HalfReader returns a Reader that implements Read
by reading half as many requested bytes from r.
</p>

          
  

        
          <h2 data-kind="f" id="NewReadLogger">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/logger.go#L52" title="View Source">NewReadLogger</a>  </h2>
          <p>
NewReadLogger returns a reader that behaves like r except
that it logs (using log.Print) each read to standard error,
printing the prefix and the hexadecimal data read.
</p>

          
  

        
          <h2 data-kind="f" id="NewWriteLogger">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/logger.go#L30" title="View Source">NewWriteLogger</a>  </h2>
          <p>
NewWriteLogger returns a writer that behaves like w except
that it logs (using log.Printf) each write to standard error,
printing the prefix and the hexadecimal data written.
</p>

          
  

        
          <h2 data-kind="f" id="OneByteReader">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/reader.go#L15" title="View Source">OneByteReader</a>  </h2>
          <p>
OneByteReader returns a Reader that implements
each non-empty Read by reading one byte from r.
</p>

          
  

        
          <h2 data-kind="f" id="TimeoutReader">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/reader.go#L75" title="View Source">TimeoutReader</a>  </h2>
          <p>
TimeoutReader returns ErrTimeout on the second read
with no data. Subsequent calls to read succeed.
</p>

          
  

        
          <h2 data-kind="f" id="TruncateWriter">func <a href="https://github.com/golang/go/blob/master/src/testing/iotest/writer.go#L11" title="View Source">TruncateWriter</a>  </h2>
          <p>
TruncateWriter returns a Writer that writes to w
but stops silently after n bytes.
</p>

          
<div class="clearfix" id="x-footer">
  <div class="container">
    <a href="http://studygolang.com/" target="_blank">Go语言中文网</a>
    <span class="text-muted">|</span> <a href="http://golang.org/" target="_blank">Go Language</a>
    <span class="pull-right"><a href="#">Back to top</a></span>
  </div>
</div>
<script src="../assets/jquery-2.0.3.min.js"></script>
<script src="../assets/bootstrap.min.js"></script>
<script src="../assets/site.js"></script>


</div>